/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.gar.beans;

import edu.upn.sigemfi.gar.bc.AgricolaDelegate;
import edu.upn.sigemfi.gar.be.Agricola;
import java.util.List;

/**
 *
 * @author Freddy
 */
public class AgricolaController {

    private AgricolaDelegate delegado;
    private Agricola agricola;

    public AgricolaController()
    {
        delegado = new AgricolaDelegate();
    }

    public List<Agricola> getAgricolas() throws Exception{
        try{
            return delegado.listar();
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return null;
    }

    public String registrar() {
        try {
            delegado.crear(agricola);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    public String actualizar() {
        try {
            delegado.editar(agricola);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }

    public String eliminar() {
        try {
            delegado.eliminar(agricola);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "volver";
    }
    
}
